package com.espeaker.sdk.api;

import android.os.Handler;

import com.espeaker.sdk.ESpeakerParameters;
import com.espeaker.sdk.Constants;
import com.espeaker.sdk.utils.Base64Util;

public class LoginApi extends MiaoApi {
	/*
	 * 用户登录
	 */
	public void userLogin(final String phoneNum, final String password, final Handler handler) {
		new Thread() {
			@Override
			public void run() {
				try {
					String encodePassword = Base64Util.encodeStr(password);
					encodePassword = Base64Util.encodeStr(encodePassword);
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("phone_number", phoneNum,true);
					params.add("password", encodePassword,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_LOGIN, params,1);
					if (handler != null) {
						handler.obtainMessage(Constants.LOGINAPI_LOGININ, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
}
